home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 March: Reference Library / Dev.CD Mar OO RLDisk 1.toast / pc / what's new / development kits / hardware / mac os usb ddk 1.4f3 / interfaces / universalhidmodule.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-19  |  4.3 KB  |  145 lines

  1. /*
  2.     File:        UniversalHIDModule.h
  3.  
  4. */
  5. /* We are not USB specific, but we share many definitions with the USB spec*/
  6. #ifndef __UNIVERSALHIDMODULE__
  7. #define __UNIVERSALHIDMODULE__
  8.  
  9. #ifndef __MACTYPES__
  10. #include <MacTypes.h>
  11. #endif
  12. #ifndef __USB__
  13. #include <USB.h>
  14. #endif
  15.  
  16.  
  17.  
  18. #if PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. #if PRAGMA_IMPORT
  27. #pragma import on
  28. #endif
  29.  
  30. #if PRAGMA_STRUCT_ALIGN
  31.     #pragma options align=mac68k
  32. #elif PRAGMA_STRUCT_PACKPUSH
  33.     #pragma pack(push, 2)
  34. #elif PRAGMA_STRUCT_PACK
  35.     #pragma pack(2)
  36. #endif
  37.  
  38. typedef UInt32                             UHIDModuleConnectionID;
  39. /* FunctionPtr to be called when inturrupt occurs*/
  40. typedef CALLBACK_API_C( void , UHIDInterruptProcPtr )(void *theData, UInt32 refcon);
  41. /* FunctionPtr definitions for UniversalHIDModule dispatch table*/
  42. typedef CALLBACK_API_C( OSStatus , UHIDGetDeviceInfoProcPtr )(UInt32 inInfoSelector, void *outInfo);
  43. typedef CALLBACK_API_C( OSStatus , UHIDGetHIDDescriptorProcPtr )(UInt32 inDescriptorType, UInt32 inDescriptorIndex, UInt32 *ioBufferSize, void *outBuffer);
  44. typedef CALLBACK_API_C( OSStatus , UHIDClaimDeviceProcPtr )(UHIDModuleConnectionID *outConnectionID, UInt32 reserved);
  45. typedef CALLBACK_API_C( OSStatus , UHIDReleaseDeviceProcPtr )(UHIDModuleConnectionID inConnectionID);
  46. typedef CALLBACK_API_C( OSStatus , UHIDInstallInterruptProcPtr )(UHIDModuleConnectionID inConnectionID, UHIDInterruptProcPtr inInterruptProc, UInt32 inRefcon);
  47. typedef CALLBACK_API_C( OSStatus , UHIDControlDeviceProcPtr )(UHIDModuleConnectionID inConnectionID, UInt32 inControlSelector, void *ioControlData);
  48.  
  49. enum {
  50.     kCurrentDispatchTableVersion = 5,
  51.     kOldestCompatableDispatchTableVersion = 5
  52. };
  53.  
  54. /*
  55.    UHIDModuleDispatchTable is exported by the HIDModule's PEF container
  56.    dispatchTableCurrentVersion is kCurrentDispatchTableVersion
  57.    dispatchTableOldestVersion is kOldestCompatableDispatchTableVersion
  58.           (the oldest built client using this API that this UHIDModule will work with)
  59.    vendorID is who wrote this UniversalHIDModule (hi word of 0 and USB vendorID is valid)
  60. */
  61.  
  62. struct UHIDModuleDispatchTableStruct {
  63.     UInt16                             dispatchTableCurrentVersion;
  64.     UInt16                             dispatchTableOldestVersion;
  65.     UInt32                             vendorID;
  66.     UInt32                             vendorSpecific;
  67.     UInt32                             reserved;
  68.     UHIDGetDeviceInfoProcPtr         pUHIDGetDeviceInfo;
  69.     UHIDClaimDeviceProcPtr             pUHIDClaimDevice;
  70.     UHIDReleaseDeviceProcPtr         pUHIDReleaseDevice;
  71.     UHIDInstallInterruptProcPtr     pUHIDInstallInterrupt;
  72.     UHIDControlDeviceProcPtr         pUHIDControlDevice;
  73.     UHIDGetHIDDescriptorProcPtr     pUHIDGetHIDDescriptor;
  74. };
  75. typedef struct UHIDModuleDispatchTableStruct UHIDModuleDispatchTableStruct;
  76.  
  77. typedef UHIDModuleDispatchTableStruct     UHIDModuleDispatchTable;
  78. typedef UHIDModuleDispatchTableStruct *    UHIDModuleDispatchTablePtr;
  79. /* the prototypes for the actual functions in the UHIDModule follow*/
  80. EXTERN_API_C( OSStatus )
  81. UHIDGetDeviceInfo                (UInt32                 inInfoSelector,
  82.                                  void *                    outInfo);
  83.  
  84. EXTERN_API_C( OSStatus )
  85. UHIDGetHIDDescriptor            (UInt32                 inDescriptorType,
  86.                                  UInt32                 inDescriptorIndex,
  87.                                  UInt32 *                ioBufferSize,
  88.                                  void *                    outBuffer);
  89.  
  90. /* Claim and release are a way to insure that only one client is connected*/
  91. EXTERN_API_C( OSStatus )
  92. UHIDClaimDevice                    (UHIDModuleConnectionID * outConnectionID,
  93.                                  UInt32                 reserved);
  94.  
  95. EXTERN_API_C( OSStatus )
  96. UHIDReleaseDevice                (UHIDModuleConnectionID  inConnectionID);
  97.  
  98. EXTERN_API_C( OSStatus )
  99. UHIDInstallInterrupt            (UHIDModuleConnectionID  inConnectionID,
  100.                                  UHIDInterruptProcPtr     inInterruptProc,
  101.                                  UInt32                 inRefcon);
  102.  
  103. EXTERN_API_C( OSStatus )
  104. UHIDControlDevice                (UHIDModuleConnectionID  inConnectionID,
  105.                                  UInt32                 inControlSelector,
  106.                                  void *                    ioControlData);
  107.  
  108. /* these are the constants to be passed to UHIDControlDevice*/
  109.  
  110. enum {
  111.     kUHIDRemoveInterruptHandle    = 0,
  112.     kUHIDVendorSpecificControlStart = 0x00010000
  113. };
  114.  
  115. /* these are the constants to be passed to UHIDGetDeviceInfo*/
  116.  
  117. enum {
  118.     kUHIDGetVendorID            = 0,
  119.     kUHIDGetProductID            = 1,
  120.     kUHIDGetMaxPacketSize        = 2,
  121.     kUHIDVendorSpecificGetInfoStart = 0x00010000
  122. };
  123.  
  124.  
  125. #if PRAGMA_STRUCT_ALIGN
  126.     #pragma options align=reset
  127. #elif PRAGMA_STRUCT_PACKPUSH
  128.     #pragma pack(pop)
  129. #elif PRAGMA_STRUCT_PACK
  130.     #pragma pack()
  131. #endif
  132.  
  133. #ifdef PRAGMA_IMPORT_OFF
  134. #pragma import off
  135. #elif PRAGMA_IMPORT
  136. #pragma import reset
  137. #endif
  138.  
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142.  
  143. #endif /* __UNIVERSALHIDMODULE__ */
  144.  
  145.